package com.woniu.repaircenter.service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.repaircenter.models.dto.HousingMaterialDTO;
import com.woniu.repaircenter.models.param.SearchMaterialParam;
import com.woniu.repaircenter.models.param.UpdateMaterialParam;
import com.woniu.repaircenter.service.model.HousingMaterial;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


import java.util.List;

/**
 * <p>
 * 材料表 Mapper 接口
 * </p>
 *
 * @author 吕雨泽
 * @since 2024年12月06日
 */
@Mapper
public interface HousingMaterialMapper extends BaseMapper<HousingMaterial> {

    @Update("update housing_material set state=1 where material_code=#{housingMaterialCode} and state=0")
    Integer removeMaterial(@Param("housingMaterialCode") String housingMaterialCode);

    List<HousingMaterialDTO> searchHousingMaterialList(@Param("searchMaterialParam") SearchMaterialParam searchMaterialParam);

    Integer updateHousingMaterial(@Param("param") UpdateMaterialParam param);

    @Update("update housing_material set state=0 where material_code=#{housingMaterialCode} and state=1")
    Integer recoverMaterial(String housingMaterialCode);

    HousingMaterial seatateHousingMaterial(@Param("materialCode") String materialCode);

    Integer updateHousingInventory(@Param("materialCode") String materialCode, @Param("count") Integer count);

    Integer updateHousing(String materialCode, Integer count);

    @Select("select material_all_name from housing_material where material_code=#{materialCode}")
    String selectMaterialAllName(@Param("materialCode") String materialCode);
}
